home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qdragobject.h.z / qdragobject.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  3.4 KB  |  147 lines

  1. /****************************************************************************
  2. ** $Id: qdragobject.h,v 2.21 1998/07/03 00:09:32 hanord Exp $
  3. **
  4. ** Definition of QDragObject
  5. **
  6. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  7. **
  8. ** This file is part of Qt Free Edition, version 1.40.
  9. **
  10. ** See the file LICENSE included in the distribution for the usage
  11. ** and distribution terms, or http://www.troll.no/free-license.html.
  12. **
  13. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  14. ** your own programs or libraries.
  15. **
  16. ** Please see http://www.troll.no/pricing.html for information about 
  17. ** Qt Professional Edition, which is this same library but with a
  18. ** license which allows creation of commercial/proprietary software.
  19. **
  20. *****************************************************************************/
  21.  
  22. #ifndef QDRAGOBJECT_H
  23. #define QDRAGOBJECT_H
  24.  
  25. struct QDragData;
  26. struct QStoredDragData;
  27. class QWidget;
  28.  
  29. #ifndef QT_H
  30. #include "qobject.h"
  31. #include "qimage.h"
  32. #include "qstrlist.h"
  33. #endif // QT_H
  34.  
  35.  
  36. class QDragObject: public QObject {
  37.     Q_OBJECT
  38. public:
  39.     QDragObject( QWidget * dragSource = 0, const char * name = 0 );
  40.     ~QDragObject();
  41.  
  42.     bool drag();
  43.     bool dragMove();
  44.     void dragCopy();
  45.  
  46.     virtual bool provides(const char*) const;
  47.     virtual const char * format(int) const=0;
  48.     virtual QByteArray encodedData(const char*) const=0;
  49.  
  50.     QWidget * source();
  51.  
  52.     enum DragMode { DragDefault, DragCopy, DragMove, DragCopyOrMove };
  53.  
  54. protected:
  55.     virtual bool drag(DragMode);
  56.  
  57. private:
  58.     QDragData * d;
  59. };
  60.  
  61. class QStoredDrag: public QDragObject {
  62.     Q_OBJECT
  63.     QStoredDragData * d;
  64.  
  65. public:
  66.     QStoredDrag( const char * mimeType,
  67.          QWidget * dragSource = 0, const char * name = 0 );
  68.     ~QStoredDrag();
  69.  
  70.     void setEncodedData( const QByteArray & );
  71.  
  72.     const char * format(int i) const;
  73.     virtual QByteArray encodedData(const char*) const;
  74. };
  75.  
  76. class QTextDrag: public QStoredDrag {
  77.     Q_OBJECT
  78. public:
  79.     QTextDrag( const char *,
  80.            QWidget * dragSource = 0, const char * name = 0 );
  81.     QTextDrag( QWidget * dragSource = 0, const char * name = 0 );
  82.     ~QTextDrag();
  83.  
  84.     void setText( const char * );
  85.  
  86.     static bool canDecode( QDragMoveEvent* e );
  87.     static bool decode( QDropEvent* e, QString& s );
  88. };
  89.  
  90.  
  91. class QImageDrag: public QDragObject {
  92.     Q_OBJECT
  93.     QImage img;
  94.     QStrList ofmts;
  95.  
  96. public:
  97.     QImageDrag( QImage image,
  98.         QWidget * dragSource = 0, const char * name = 0 );
  99.     QImageDrag( QWidget * dragSource = 0, const char * name = 0 );
  100.     ~QImageDrag();
  101.  
  102.     void setImage( QImage image );
  103.  
  104.     const char * format(int i) const;
  105.     virtual QByteArray encodedData(const char*) const;
  106.  
  107.     static bool canDecode( QDragMoveEvent* e );
  108.     static bool decode( QDropEvent* e, QImage& i );
  109.     static bool decode( QDropEvent* e, QPixmap& i );
  110. };
  111.  
  112.  
  113. // QDragManager is not part of the public API.  It is defined in a
  114. // header file simply so different .cpp files can implement different
  115. // member functions.
  116. //
  117.  
  118. class QDragManager: public QObject {
  119.     Q_OBJECT
  120.  
  121. private:
  122.     QDragManager();
  123.     ~QDragManager();
  124.     // only friend classes can use QDragManager.
  125.     friend class QDragObject;
  126.  
  127.     bool eventFilter( QObject *, QEvent * );
  128.  
  129.     bool drag( QDragObject *, QDragObject::DragMode );
  130.  
  131.     void cancel();
  132.     void move( const QPoint & );
  133.     void drop();
  134.  
  135. private:
  136.     QDragObject * object;
  137.  
  138.     QWidget * dragSource;
  139.     QWidget * dropWidget;
  140.     bool beingCancelled;
  141.     bool restoreCursor;
  142.     bool willDrop;
  143. };
  144.  
  145.  
  146. #endif
  147.